package com.qhg.saas_server.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qhg.saas_server.mapper.CompanyMapper;
import com.qhg.saas_server.mapper.ComployeeMapper;
import com.qhg.saas_server.pojo.Comployee;
import com.qhg.saas_server.pojo.dto.ComployeeInfoDto;
import com.qhg.saas_server.pojo.dto.PagingDto;
import com.qhg.saas_server.service.ComployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ComployeeServiceImpl implements ComployeeService {

    @Autowired
    ComployeeMapper comployeeMapper;

    @Override
    public PageInfo SelectComployee(Integer pageNum,Integer pageSize, String comploName, String departName) {
        PageHelper.startPage(pageNum,pageSize);
        List<ComployeeInfoDto> comployeeInfoDtos = comployeeMapper.SelectComployee(comploName, departName);
        PageInfo<ComployeeInfoDto> comployeePageInfo = new PageInfo<ComployeeInfoDto>(comployeeInfoDtos);
        return comployeePageInfo;
    }

    @Override
    public ComployeeInfoDto SelectById(Integer comploId) {
        return comployeeMapper.SelectById(comploId);
    }

    @Override
    public void InsertComployee(Comployee comployee) {
        comployeeMapper.InsertComployee(comployee);
    }

    @Override
    public void UpdateComployee(Comployee comployee) {
        comployeeMapper.UpdateComployee(comployee);
    }

    @Override
    public void UpdatePassword(Integer comploId, String comploPassword) {
        comployeeMapper.UpdatePassword(comploId,comploPassword);
    }

    @Override
    public void UpdateStauts(Integer comploStatus, Integer comploId) {
        comployeeMapper.UpdateStauts(comploStatus,comploId);
    }

    @Override
    public void DeleteComployeeById(Integer comploId) {
        comployeeMapper.DeleteComployeeById(comploId);
    }

    @Override
    public PageInfo SelectRComployee(Integer pageNum,Integer pageSize, String comploName, String departName) {
        PageHelper.startPage(pageNum,pageSize);
        List<ComployeeInfoDto> comployeeInfoDtos = comployeeMapper.SelectRComployee(comploName, departName);
        PageInfo<ComployeeInfoDto> comployeePageInfo = new PageInfo<ComployeeInfoDto>(comployeeInfoDtos);
        return comployeePageInfo;
    }
}
